package com.juc.forkJoinPool.forkJoinPool5;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;

public class Run {

	// public ForkJoinTask<?> submit(Runnable task)
	//任务执行 传入Runnable虽然没有返回值但调用get()方法呈阻塞状态
	public static void main(String[] args) throws InterruptedException, ExecutionException {
		ForkJoinPool pool =new ForkJoinPool();
		System.out.println("begin " + System.currentTimeMillis());
		ForkJoinTask<?> task = pool.submit(new Runnable() {
			
			@Override
			public void run() {
				try {
					Thread.sleep(5000);
					System.out.println("ThreadName  " + Thread.currentThread().getName());
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		});
		System.out.println(task.get());
		System.out.println("end " + System.currentTimeMillis());
		Thread.sleep(5000);
	}
}
